home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
hity wydania
/
Bank smakow
/
BankSmakow.air
/
BankSmakow.swf
/
scripts
/
air
/
update
/
states
/
HSM.as
next >
Wrap
Text File
|
2009-12-16
|
2KB
|
86 lines
package air.update.states
{
import flash.errors.IllegalOperationError;
import flash.events.ErrorEvent;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class HSM extends EventDispatcher
{
private var asyncTimer:Timer;
private var _hsmState:Function;
public function HSM(param1:Function)
{
super();
_hsmState = param1;
}
public function init() : void
{
try
{
_hsmState(new HSMEvent(HSMEvent.ENTER));
}
catch(e:Error)
{
_hsmState(new ErrorEvent(ErrorEvent.ERROR,false,false,e.message,e.errorID));
}
}
protected function get stateHSM() : Function
{
return _hsmState;
}
protected function transition(param1:Function) : void
{
var state:Function = param1;
asyncTimer = null;
try
{
_hsmState(new HSMEvent(HSMEvent.EXIT));
_hsmState = state;
_hsmState(new HSMEvent(HSMEvent.ENTER));
}
catch(e:Error)
{
_hsmState(new ErrorEvent(ErrorEvent.ERROR,false,false,"Unhandled exception " + e.name + ": " + e.message,e.errorID));
}
}
protected function transitionAsync(param1:Function) : void
{
var state:Function = param1;
if(asyncTimer)
{
throw new IllegalOperationError("async transition already queued");
}
asyncTimer = new Timer(0,1);
asyncTimer.addEventListener(TimerEvent.TIMER,function(param1:Event):void
{
transition(state);
});
asyncTimer.start();
}
public function dispatch(param1:Event) : void
{
var event:Event = param1;
try
{
_hsmState(event);
}
catch(e:Error)
{
_hsmState(new ErrorEvent(ErrorEvent.ERROR,false,false,e.message,e.errorID));
}
}
}
}